package com.java110.mall.cart.bmo.businessQuery.impl;

import com.alibaba.fastjson.JSONObject;
import com.java110.dto.product.ProductGroupDto;
import com.java110.dto.product.ProductGroupOrderDto;
import com.java110.intf.goods.IProductGroupOrderV1InnerServiceSMO;
import com.java110.intf.goods.IProductGroupV1InnerServiceSMO;
import com.java110.mall.cart.bmo.businessQuery.IBusinessQueryGroup;
import com.java110.utils.util.ListUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusinessQueryGroupImpl implements IBusinessQueryGroup {
    @Autowired
    private IProductGroupV1InnerServiceSMO productGroupV1InnerServiceSMOImpl;

    @Autowired
    private IProductGroupOrderV1InnerServiceSMO productGroupOrderV1InnerServiceSMOImpl;

    @Override
    public void queryGroupByGoodsName(JSONObject reqJson, String searchValue, String shopId, List<ProductGroupDto> allProductGroupDtos) {

        ProductGroupDto productGroupDto = new ProductGroupDto();
        productGroupDto.setShopId(shopId);
        productGroupDto.setPage(1);
        productGroupDto.setRow(10);
        productGroupDto.setProdNameLike(searchValue);
        List<ProductGroupDto> productGroupDtos = productGroupV1InnerServiceSMOImpl.queryProductGroups(productGroupDto);
        if (ListUtil.isNull(productGroupDtos)) {
            return;
        }
        allProductGroupDtos.addAll(productGroupDtos);
    }

    @Override
    public void queryGroupByProductId(JSONObject reqJson, String searchValue, String shopId, List<ProductGroupDto> allProductGroupDtos) {
        ProductGroupDto productGroupDto = new ProductGroupDto();
        productGroupDto.setShopId(shopId);
        productGroupDto.setPage(1);
        productGroupDto.setRow(10);
        productGroupDto.setProductId(searchValue);
        List<ProductGroupDto> productGroupDtos = productGroupV1InnerServiceSMOImpl.queryProductGroups(productGroupDto);
        if (ListUtil.isNull(productGroupDtos)) {
            return;
        }
        allProductGroupDtos.addAll(productGroupDtos);
    }

    @Override
    public void queryGroupOrderByGroupId(JSONObject reqJson, String searchValue, String shopId, List<ProductGroupOrderDto> allProductGroupOrderDtos) {
        ProductGroupOrderDto productGroupOrderDto = new ProductGroupOrderDto();
        productGroupOrderDto.setGroupId(searchValue);
        productGroupOrderDto.setShopId(shopId);
        productGroupOrderDto.setPage(1);
        productGroupOrderDto.setRow(10);
       List<ProductGroupOrderDto> productGroupOrderDtos = productGroupOrderV1InnerServiceSMOImpl.queryProductGroupOrders(productGroupOrderDto);
        if (ListUtil.isNull(productGroupOrderDtos)) {
            return;
        }
        allProductGroupOrderDtos.addAll(productGroupOrderDtos);
    }

}
